import React, { Component } from 'react'
import Topic from './topic/topic.js'
import Ranklist from './ranklist/ranklist.js'
import 'antd-mobile/dist/antd-mobile.css'; 
import Home_header from './home_header/home_header'
import Swiper from './swiper/home_swiper'
import Home_grid from './home_grid/home_grid'
import Market from './market/market'
import axios from 'axios'
import style from './home.module.css'

import Foot from "../../components/foot_router/foot_router"
import HouseList from '../../components/shoplist/list_main_List'
import Chouti from '../list/chouti/chouti'
export default class Center extends Component {
    state ={
        topciList:[],
        shoplist:[],
        flag: false,
        time:""
    }
    componentDidMount(){
        const headerJSON = {
            "Content-Type": "application/json;charset=UTF-8"
        };
        axios({
            url:"/shop/search",
            method:"post",
            header:headerJSON,
            data:{
                places:"沈阳市"
            }
        }).then(res=>{
            this.setState({
                shoplist:res.data.lists,
                time:new Date().getTime()
            })
        })
        this.setState({})
    }
    changeChouti = () => {
        clearTimeout(this.state.iTime);
        this.state.iTime = setTimeout(() => {
            this.state.flag = !this.state.flag
            this.setState({})
        }, 200);

    }
    render() {
        let {shoplist} = this.state

        let now= new Date();
        let _month = now.getMonth()+1;
        let _day = now.getDate();
        let time =   _month + '月' + _day+'日'
        console.log(time,"time")

        return (
            <div className={style.big}>
            <Home_header key={this.state.flag} changeChouti={this.changeChouti}></Home_header>
            <Swiper></Swiper>
            <Home_grid></Home_grid>
                          
            {/* 头条 */}
            <div className={style.headlines}>
                <div className={style.headlinesLeft}>
                    <i>品房头条</i>

                    <div className={style.headlinesDate}>
                       {time}
                    </div>
                </div>
                <ul className={style.headlinesRight}>
                    <li className={style.rightCon}>· 保利浅海时光里 | “1”字头总价三亚海洋</li>
                    <li className={style.rightCon}>· 热惠推荐 | 三亚怡康雅园海景美宅 均价</li>
                </ul>
            </div>
            <Market></Market>
            <Topic></Topic>
            <Ranklist></Ranklist>
            <div className={style.houselist}>
                <p className={style.houselistTil}>必看好房</p>
            <HouseList shoplist={shoplist}></HouseList>
            </div>
            <Chouti flag={this.state.flag} changeChouti={this.changeChouti}/>
            <Foot/>
            </div>
        )
    }
}
